<? include_once("./class/Usuario.class.php"); ?>
<?php 
session_start();

if (!$_SESSION["admin"]) header("Location: login.php"); 

$unUsuario = $_SESSION["admin"];
?>
<? include_once("facturasListar.code.php"); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><!-- InstanceBegin template="Templates/Master.dwt.php" codeOutsideHTMLIsLocked="false" -->
<head>
<!-- InstanceBeginEditable name="doctitle" -->
  <title>MagicInvoices</title>
  <!-- InstanceEndEditable -->
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  <meta name="description" content="PuertoPago" />
  <meta name="author" content="ARothar" />
  <meta name="robots" content="nofollow" />   
  
  <script src="js/jquery-1.4.2.js" type="text/javascript"></script> 
  <script src="js/jquery.validate.js" type="text/javascript" ></script>
  <script type='text/javascript' src='js/loadmask/jquery.loadmask.min.js'></script>
	<script type="text/javascript">
        /* Hide messages and tooltip configuration */
        $(function() {
                // Hide divs
                // Enter the class 'hidethis' in a div and you can hide it
                // when you click it, used here for the message divs
                $("div.hidethis").click(function(){$(this).slideUp("fast");});
        
                // Tooltip Configuration
                // Enter one of the following classes (eg 'tooltip-top') to an element and to the
                // title attribute of it add the text you want to appear in the tooltip.
                // You can set the fade to true for a fade in/out effect
                $('.tooltip-top').tipsy({fade: false, gravity: 's'});
                $('.tooltip-right').tipsy({fade: false, gravity: 'w'});
                $('.tooltip-bottom').tipsy({fade: false, gravity: 'n'});
                $('.tooltip-left').tipsy({fade: false, gravity: 'e'});
        });
		$(document).ready(function(){
			$("#container").ajaxStart(function(){
				$("#container").mask("Procesando...");
			});
			$("#container").ajaxStop(function(){
				$("#container").unmask();
			});
		});
		
    </script>
   
  <!-- Favicon & styles -->
  <link rel="shortcut icon" href="img/favicon.ico" />
  <link type="text/css" rel="stylesheet" href="css/style.css" />
  <link rel='stylesheet' type='text/css' href='js/loadmask/jquery.loadmask.css' />
  <!-- Skins (uncomment the style you want to change the skin) -->
    <!-- <link type="text/css" rel="stylesheet" href="css/skins/green.css" /> -->
    <!-- <link type="text/css" rel="stylesheet" href="css/skins/darkred.css" /> -->
    <!-- <link type="text/css" rel="stylesheet" href="css/skins/purple.css" /> -->
  <!-- END OF Skins -->
  
  <!-- Markitup styles -->
  <link type="text/css" rel="stylesheet" href="js/markitup/skins/markitup/style.css" />
  <link type="text/css" rel="stylesheet" href="js/markitup/sets/default/style.css" />
  
	<!--[if IE 6]>
		<link type="text/css" rel="stylesheet" href="css/ie6.css" />
	<![endif]-->
  <!--[if IE]>
  <style type="text/css">
    .clearfix {
      zoom: 1;     /* triggers hasLayout */
      display: block;     /* resets display for IE/Win */
      }  /* Only IE can see inside the conditional comment
      and read this CSS rule. Don't ever use a normal HTML
      comment inside the CC or it will close prematurely. */
  </style>
  <![endif]-->
  <!-- END OF Favicon & styles -->
  <!-- InstanceBeginEditable name="head" -->
<!-- InstanceEndEditable -->
</head>

<body>
	
  <!-- Push a little! -->
  <div class="push"></div>
 
  <!-- Container, holds the page -->
  <div id="container">
  
  	<!-- Header -->
    <div id="header">
      <div id="logo"><a href="index.php" class="logo"><img src="img/logo-web-facturas.png" /></a></div>
    <? if ($_SESSION["admin"]) { ?>
      <div id="admin-details">
        <img src="img/avatar.png" alt="avatar" />
        Bienvenido <strong><?=$unUsuario->alias ?></strong>! <a href="inc/admin.logout.php" class="a-red">Logout?</a><br />
      </div>
          <? } ?>
    </div>

    <!-- END OF Header -->
    
    <!-- A div with clearfix to hold the floated divs inside -->
  	<div class="clearfix">
    
    	<!-- Content -->
      <div id="content">
      	<!-- Main navigation OLD
        <div id="nav" class="clearfix">
          <ul id="nav-menu">
            <li><a href="#" class="active">Dashboard</a></li>
            <li><a href="#">Posts</a></li>
            <li><a href="#">Users</a></li>
            <li><a href="#">Comments</a></li>
            <li><a href="#">Newsletter</a></li>
            <li><a href="#">Settings</a></li>
          </ul>
        </div>
        END OF Main Navigation OLD -->

        <!-- Main navigation NEW -->
        <div id="nav">
          <ul id="jsddm" class="clearfix">
          	<? if ($unUsuario->esAdmin == 1) { ?>
            <li><a href="facturasListar.php" class="">Facturas</a></li>
            
            <li><a href="usuarioListar.php" class="">Usuario</a></li>
            <? } ?>
          </ul>
        </div>
        <!-- InstanceBeginEditable name="cuerpo" -->
<!-- Tables -->
<script src="js/jquery-ui-1.8.4.custom.min.js" type="text/javascript"></script> 
<script src="js/ui.datepicker-es.js" type="text/javascript"></script> 
<link rel="stylesheet" type="text/css" href="js/custom-theme/jquery-ui-1.8.4.custom.css">
<script type="text/javascript">
Date.format = 'yy-mm-dd';
	$(function() {
		$("#fechaHasta").datepicker({regional: 'es', dateFormat:'dd-mm-yy'});
		$("#fechaDesde").datepicker({regional: 'es', dateFormat:'dd-mm-yy'});
	});
	function cambiarPagina(pagina){
		$("#frmPrincipal").attr("action","<?=$_SERVER["PHP_SELF"]."?pagina="?>" + pagina);
		$("#frmPrincipal").submit();
	}
	function marcar(idPago){
		if (confirm("Desea marcar como pagado este Pago?")){
			$("#frmPrincipal").attr("action","<?=$_SERVER["PHP_SELF"]."?pagina="?>" + <?=$pagina?> + "&modo=pago&idPago=" + idPago);
			$("#frmPrincipal").submit();
		}
		return false;
	}
	
	function borrar(){
		if (confirm("Desea eliminar los pagos seleccionados?")){
			$("#frmPrincipal").attr("action","<?=$_SERVER["PHP_SELF"] . "?borrar=1"?>");
			$("#frmPrincipal").submit();
		}
		return false;
	}
	function ordenar(columna){
		$("#hdnOrden").val(columna);
		$("#frmPrincipal").submit();
	}
	</script>
        <h2 class="ic-db">Facturas</h2>
        <div class="pad-lr">
            <form action="<?="facturasListar.php"?>" id="frmPrincipal" method="post" onsubmit="">

            <fieldset>
                <legend>Cliente</legend>

				<div style="float: left; width: 25%; padding-left: 10px; display:block ">
                <label for="usuario">Cuit:</label>
                <br />
	                <input name="txtCuit" type="text" class="box-small tooltip-right" id="txtCuit" <?php if ($unUsuario->esAdmin != 1) { ?> disabled="disabled" <?php } ?> title="Cuit" onblur="" value="<?=$_POST['txtCuit'] ?>" />
                <br />
	            </div>
				
                <div style="font-size:62.5%; float: left; width: 25%; padding-left: 10px; display:block ">
                <label for="fechaDesde">Numero:</label><br />
                <input name="txtNumero" type="text" class="box-small tooltip-right" id="txtNumero" title="Numero de Factura" onblur="" value="<?=$_POST['txtNumero'] ?>" />
                <br />
	            </div>
				
                <div style="float: left; width: 25%; padding-left: 10px; display:block ">


                <br />
	            </div>

                <div style="float: left; width: 10%;height:0px; padding-left: 10px; display:block ">
                <label for="dd"></label>
                <br />
		        <span><input type="submit" value="Buscar" class="btn-grey radius" /></span>
                <br />
	            </div>
            </fieldset>
            <input name="hdnOrden" id="hdnOrden" type="hidden" value="<?=$_POST["hdnOrden"]?>" />
            <table>
            <tr>
                <th class="t-narrow"><input type="checkbox" /></th>
                <th>id</th>
              <th><a href="javascript:ordenar('nombre');">Archivo</a></th>
              <th><a href="javascript:ordenar('numero');">Nro Factura</a></th>
              <th>Fecha</th>
              <th>Tamaño</th>
              <!--<th>Pagado</th>-->
              <th class="center">Download</th>
            </tr>
            <?
			$i=0;
			if (count($listaFacturas)>0){;
				foreach ($listaFacturas as $id => $items) {
					if ($inicio <= $i && $final >= $i){
				?>			
					 <tr style="height:15px">
						<td class="t-color t-narrow"><? if ($items["id"] != "") { ?><input type="checkbox" value="<?=$items["id"];?>" name="chkSeleccionados[]" /><? } ?></td>
						<td class="t-color"><?=$items["id"] ?></td>
						 <td class="t-color"><a href="<?=$items["path"]?>"><?=$items["nombre"]?></a></td>
						<td class="t-color"><a href="<?=$items["path"]?>"><?=$items["numero"]?></a></td>
						<td class="t-color"><?=$items["fecha"] ?></td>
						<td class="t-color"><?=$items["size"] . " KB"?></td>
						<td class="t-color center" >
							<table cellpadding="0" cellspacing="0" style="border:0px; width:35px">
								<tr>
									<td>                
										<? if ($items["id"] != "") { ?>
											<a href="<?=$items["path"]?>" class="tooltip-top" title="Editar"><img src="img/action-edit.png" alt="action-edit" /></a>
										<? } ?></td>
									<td>&nbsp;</td>
								</tr>
							</table>
		
					   </td>
					</tr>
            <?  	}
				$i++;
				}

			}?>
            

            </table>
            </form>
          
          <div class="msg-general"></div>
          
          <div class="pagination center">
          	<span class="page-inactive">Pagina <?=$pagina ?> de <?=$numPags ?></span>
            <!--<a href="<?=$_SERVER["PHP_SELF"]."?pagina=". $paginaAnterior ?>" class="page a-dark">Previous</a>-->
			<a href="javascript:cambiarPagina(<?=$paginaAnterior?>);" class="page a-dark">Anterior</a>
            <?
			for($i=1;$i<=$numPags;$i++) 
			{
			?>
				<? if ($i == $pagina) { ?>
                    <span class="page-active"><?=$i?></span>
                <? } else {?>
                    <!--<a href="<?=$_SERVER["PHP_SELF"]."?pagina=". $i ?>" class="page a-dark"><?=$i?></a>-->
                    <a href="javascript:cambiarPagina(<?=$i?>);" class="page a-dark"><?=$i?></a>
                    
                <? } ?>
			<? } ?>
    
            <!--<a href="<?=$_SERVER["PHP_SELF"]."?pagina=". $paginaSiguiente ?>" class="page a-dark">Next</a>-->
            <a href="javascript:cambiarPagina(<?=$paginaSiguiente ?>);" class="page a-dark">Siguiente</a>
          </div>
          
        </div>
        <!-- END OF Tables -->
		<!-- InstanceEndEditable -->
      </div>
      <!-- END OF CONTENT -->
    </div>
  	<!-- END OF Div with clearfix -->
    
    <!-- Footer -->
    <div id="footer">2011 &copy; <strong>MagicInvoices</strong> by Alejandro Rothar</div>
    
  </div>
  <!-- END OF Container -->
  
  <!-- Push a little -->
  <div class="push"></div>
  
  
  <!-- Javascript -->
  
  	<!-- Jquery -->
    <!-- You can include the jquery form googleapis.com to save bandwidth -->
    <!-- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> -->
    <!-- Simple dropdown menu -->
    <script src="js/dropdown.js" type="text/javascript"></script>

    <!-- Tooltip (jquery plugin) -->
    <script src="js/jquery.tipsy.js" type="text/javascript"></script>
    
    <!-- Markitup (jquery plugin) -->
    <script src="js/markitup/jquery.markitup.pack.js" type="text/javascript"></script>
    <script src="js/markitup/sets/default/set.js" type="text/javascript"></script>
    <script src="js/jquery.markitup.config.js" type="text/javascript"></script> <!-- You can configure further the plugin in this file -->
    
    <!-- CUSTOM CODE (Character limit, sidebar functions, Twitter ajax functionality, hide messages, tooltip) -->
    <script type="text/javascript">
        /* Character limit (jquery plugin) */
        (function($){$.fn.extend({limit:function(limit,element){var interval,f;var self=$(this);$(this).focus(function(){interval=window.setInterval(substring,100)});$(this).blur(function(){clearInterval(interval);substring()});substringFunction="function substring(){ var val = $(self).val();var length = val.length;if(length > limit){$(self).val($(self).val().substring(0,limit));}";if(typeof element!='undefined')substringFunction+="if($(element).html() != limit-length){$(element).html((limit-length<=0)?'0':limit-length);}";substringFunction+="}";eval(substringFunction);substring()}})})(jQuery);
        /* END OF Character limit (jquery plugin) */

        /* Hide messages and tooltip configuration */
        $(function() {
                // Hide divs
                // Enter the class 'hidethis' in a div and you can hide it
                // when you click it, used here for the message divs
                $("div.hidethis").click(function(){$(this).slideUp("fast");});

                // Tooltip Configuration
                // Enter one of the following classes (eg 'tooltip-top') to an element and to the
                // title attribute of it add the text you want to appear in the tooltip.
                // You can set the fade to true for a fade in/out effect
                $('.tooltip-top').tipsy({fade: false, gravity: 's'});
                $('.tooltip-right').tipsy({fade: false, gravity: 'w'});
                $('.tooltip-bottom').tipsy({fade: false, gravity: 'n'});
                $('.tooltip-left').tipsy({fade: false, gravity: 'e'});
        });
        /* END OF Hide messages and tooltip configuration */

       </script>
    <!-- END OF CUSTOM CODE -->
  <!-- END OF Javascript -->
  
</body>

<!-- InstanceEnd --></html>
